home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-12-31 | 4.1 KB | 176 lines | [TEXT/MPS ] |
- {Copyright © 1986 by Apple Computer, Inc. All Rights Reserved.}
-
- UNIT UDemoText;
-
- {This sample application demonstrates the breadth of alternatives available
- when using the MacApp building-block "UTEView" for text-editing.}
-
- INTERFACE
-
- USES
- {$LOAD MacIntf.LOAD}
- MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
- {$LOAD UMacApp.LOAD}
- UObject, UList, UMacApp,
- {$LOAD}
-
- UPrinting,
-
- UTEView;
-
-
- CONST
-
- {Command numbers}
-
- cWidthFrame = 601; {View-width-determination commands}
- cWidthView = 602;
- cWidthOnePage = 603;
-
- cHeightFrame = 604; {View-height-determination commands}
- cHeightPages = 605;
- cHeightText = 606;
- cHeightConst = 607;
-
- cJustLeft = 608; {Justification commands}
- cJustCenter = 609;
- cJustRight = 610;
-
-
- {Other constants}
-
- kSignature = 'SS04'; {application signature}
- kFileType = 'TEXT'; {file-type code for saved disk files -- uses
- standard text files}
- kWindowRsrcID = 1004; {Resource ID of the WIND resource used to
- obtain the windows used by this app}
-
-
-
- TYPE
-
- TextSpecs = {Text specifications}
- RECORD
- theFontNumber: INTEGER;
- theFontSize: INTEGER;
- theStyle: Style;
- theJustification: INTEGER;
- END;
- TextSpecsPtr = ^TextSpecs;
- TextSpecsHdl = ^TextSpecsPtr;
-
-
-
- TDemoTextApplication = OBJECT(TApplication)
-
- PROCEDURE TDemoTextApplication.IDemoTextApplication;
- {Initialize the Application}
-
- FUNCTION TDemoTextApplication.DoMakeDocument(itsCmdNumber: CmdNumber):
- TDocument; OVERRIDE;
- {Launches a TTextDocument}
-
- {$IFC qDebug}
- PROCEDURE TDemoTextApplication.IdentifySoftware; OVERRIDE;
- {$ENDC}
-
- END;
-
-
-
- TTextDocument = OBJECT(TDocument)
-
- fText: Handle; {The text owned by the document}
- fTEView: TTEView; {The view which displays the text}
-
- fTextSpecs: TextSpecs; {Specifies properties of the text}
- fSpecsChanged: BOOLEAN; {Specifications have changed since last
- time menus were set up}
- fCurrFontMenu: INTEGER; {Currently selected font menu item}
-
-
- {Initialization and freeing}
-
- PROCEDURE TTextDocument.ITextDocument;
- PROCEDURE TTextDocument.Free; OVERRIDE;
- PROCEDURE TTextDocument.DoInitialState; OVERRIDE;
- PROCEDURE TTextDocument.FreeData; OVERRIDE;
-
-
- {Filing}
-
- PROCEDURE TTextDocument.DoNeedDiskSpace(VAR dataForkBytes,
- rsrcForkBytes: LONGINT); OVERRIDE;
- PROCEDURE TTextDocument.DoRead(aRefNum: INTEGER; rsrcExists,
- forPrinting: BOOLEAN); OVERRIDE;
- PROCEDURE TTextDocument.DoWrite(aRefNum: INTEGER; makingCopy: BOOLEAN);
- OVERRIDE;
-
-
- {Making views and windows}
-
- PROCEDURE TTextDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
- PROCEDURE TTextDocument.DoMakeWindows; OVERRIDE;
-
-
- {Command processing}
-
- FUNCTION TTextDocument.DoMenuCommand(aCmdNumber: CmdNumber): TCommand;
- OVERRIDE;
- PROCEDURE TTextDocument.DoSetupMenus; OVERRIDE;
-
-
- {Auxiliary routine}
-
- PROCEDURE TTextDocument.InstallTextSpecs(specs: TextSpecs);
- {Installs the properties implied by values in 'specs' into the
- TextEdit record}
-
- PROCEDURE TTextDocument.ShowReverted; OVERRIDE;
- {When the user reverts a document, this is called after reading
- the old document and before displaying it. Causes the reverted
- font specs to be installed.}
-
- END;
-
-
-
- TTextCommand = OBJECT(TCommand) {A Command which changes properties of text}
-
- fOldTextSpecs: TextSpecs; {Text specifications before command is
- done -- used for UNDO}
- fNewTextSpecs: TextSpecs; {Text specifications after command is
- done -- used for DO/REDO}
-
- fTEView: TTEView; {The view to which the command applies}
- fTextDocument: TTextDocument; {The corresponding text document}
-
-
- {Initialization}
-
- PROCEDURE TTextCommand.ITextCommand(itsCmdNumber: CmdNumber;
- itsTextDocument: TTextDocument;
- itsTEView: TTEView;
- itsFontNumber: INTEGER;
- itsFontSize: INTEGER;
- itsStyle: Style;
- itsJustification: INTEGER);
-
-
- {Command execution phases}
-
- PROCEDURE TTextCommand.DoIt; OVERRIDE;
- PROCEDURE TTextCommand.UndoIt; OVERRIDE;
- PROCEDURE TTextCommand.RedoIt; OVERRIDE;
-
- END;
-
-
-
- IMPLEMENTATION
-
- {$I UDemoText.inc1.p}
-
- END.
-
-